import { createI18n } from "vue-i18n";
import zh from "@/locales/zh";
import en from "@/locales/en";

const getStorage = (key: string) => {
  return localStorage.getItem(key)
    ? JSON.parse(localStorage.getItem(key) as string)
    : "";
};

const i18n = createI18n({
  locale: getStorage("locales") || "zh",
  messages: {
    zh,
    en,
  },
  fallbackLocale: "zh",
});

export default i18n;
